﻿
using UnityEngine;

namespace lights.polytool.editor
{
    public static class GUITool
    {
        static int btnfontSize;
        static Color contentColor;
        static int labelfontSize;
        static Color backColor;
        public static void Record()
        {
            btnfontSize= GUI.skin.button.fontSize;
            labelfontSize= GUI.skin.label.fontSize;
            contentColor = GUI.contentColor;
            backColor = GUI.backgroundColor;
        }
        public static void Restore()
        {
            GUI.contentColor = contentColor;
        
            GUI.skin.button.fontSize = btnfontSize;

            GUI.skin.label.fontSize = labelfontSize;
            GUI.backgroundColor = backColor;
        }
        public static bool BackColorButton(string text,Color color)
        {
            Record();
           
            GUI.backgroundColor = color;
            var b =GUILayout.Button(text);
            Restore();
            return b;
        }
        public static void ColorLabel(string text,int fontsize,Color color)
        {
            Record();
            GUI.skin.label.fontSize = fontsize;
            GUI.contentColor = color;
            GUILayout.Label(text);
            Restore();
        }
        public static bool ColorButton(string text,int fontsize,Color color)
        {
            Record();
            GUI.skin.button.fontSize = fontsize;
            GUI.contentColor = color;
            var b=GUILayout.Button(text);
            Restore();
            return b;
        }
    }
}
